package xyz.zhno.mall.common.core.exception;

import lombok.Getter;
import xyz.zhno.mall.common.core.enums.ErrorCodeEnum;

/**
 * 自定义异常
 * @author zh_o
 */
@Getter
public class APIException extends RuntimeException {

    /**
     * 错误码
     */
    private final String code;

    public APIException(String message) {
        super(message);
        this.code = ErrorCodeEnum.SERVER_ERROR.getCode();
    }

    public APIException(String code, String message) {
        super(message);
        this.code = code;
    }

    public APIException(ErrorCodeEnum errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

}
